version: "3.8"

services:
  gitea:
    image: gitea/gitea:1.16.5
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - DB_TYPE=mysql
      - DB_HOST=localhost:3306
      - DB_NAME=gitea
      - DB_USER=gitea
      - SSH_PORT=2224
    volumes:
      - /data/gitea:/data
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "3000:3000"
      - "2224:2224"
    networks:
      - "default"
    deploy:
      mode: replicated
      replicas: 1
      labels:
        - "traefik.enable=true"
        - "traefik.docker.network=default"
        - "traefik.http.services.gitea_gitea.loadbalancer.server.port=3000"
        # http 80
        - "traefik.http.routers.gitea.rule=Host(`gitea.localhost.com`)" 
        - "traefik.http.routers.gitea.entrypoints=web"
      placement:
        constraints: [node.role == manager]
      restart_policy:
        condition: on-failure
        delay: 5s
        max_attempts: 3
        window: 120s
networks:
  default:
    external:
      name: traefik_default
